#include "Entity2D.h"

Entity2D::Entity2D(){
	posX = posY = posZ = 0;
	sizeX = sizeY = 0;
	visible = false;
	name = "";
	vtxCount = 0;
	primType = D3DPRIMITIVETYPE::D3DPT_POINTLIST;
	vertices = NULL;
}

void Entity2D::Draw(Renderer* renderer){
	renderer->SetMatrixMode(World);
	renderer->LoadIdentity();
	renderer->Translate(posX,posY,posZ);
	renderer->RotateZ(rotation*3.14159f/180.0f);
	renderer->Scale(sizeX,sizeY);
	if(visible)		
		renderer->Draw(vertices,primType,vtxCount);
}

void Entity2D::SetColor(DWORD color){
	for (int i=0;i<4;i++){
		vertices[i].color=color;
	}
}
void Entity2D::SetVertexColor(int i,DWORD color){
	if(i<vtxCount)
		vertices[i].color=color;
}